/**
 * 
 * The MIT License
 * 
 * Copyright (c) 2008 the original author or authors.
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */

package com.googlecode.gchartjava;

/**
 * Class that encapsulates data for a {@link BarChart}.
 *
 * @author Julien Chastang (julien.c.chastang at gmail dot com)
 * 
 * @see BarChart
 */
public class BarChartDataSeries {
	private final Data   data;
	private final Color  color;

	private String legend;
	private Color fillAreaColor;
	private DataLine dataLine;
	
	/**
	 * Define a bar chart series. This data will be rendered by BarChart.
	 * 
	 * @param data
	 *            Data for this bar chart series.
	 * @param color
	 *            Color for this bar chart series.
	 *            
	 * @see Data
	 * @see DataUtil
	 * @see Color
	 */
	public BarChartDataSeries(final Data data, final Color color) {
		this.data   = data;
		this.color  = color;
	}

	/**
	 * Define a bar chart series. This data will be rendered by BarChart.
	 * 
	 * @param data
	 *            Data for this bar chart series.
	 * @param color
	 *            Color for this bar chart series.
	 * @param legend
	 *            Legend for this bar chart series.
	 * @see Data
	 * @see DataUtil
	 * @see Color
	 */
	public BarChartDataSeries(final Data data, final Color color, final String legend) {
		this.data   = data;
		this.color  = color;
		this.legend = legend;
	}

	/**
	 * Get the data associated with this bar chart series.
	 * 
	 * @return Data.
	 * 
	 * @see Data
	 */
	public Data getData() {
		return data;
	}

	/**
	 * Get the color of this bar chart series.
	 * 
	 * @return Color.
	 * 
	 * @see Color
	 */
	public Color getColor() {
		return color;
	}
	
	/**
	 * Return the legend associated with this bar chart series.
	 * 
	 * @return Text legend.
	 */
	public String getLegend(){
		return legend;
	}

	/**
	 * Add a data line on top of the bar chart and specify the color and
	 * {@link Priority} of that line.
	 * 
	 * @param dataLineSize
	 *            The line thickness for this data line.
	 * @param color
	 *            The color of this data line.
	 * 
	 * @param priority
	 *            The priority of this data line.
	 * 
	 * 
	 * @see Color
	 * @see Priority
	 */
	public void setDataLineStyle(final int dataLineSize, final Color color, final Priority priority) {
		this.dataLine = new DataLine(dataLineSize,color,priority);
	}

	/**
	 * Get the bar chart data line.
	 * 
	 * @return The data line that will rest on top of this bar chart series.
	 */
	public DataLine getDataLine() {
		return dataLine;
	}
	
	/**
	 * Get the fill area color that will sit behind this bar chart.
	 * 
	 * @return The fill area color.
	 * 
	 * @see Color
	 */
	public Color getFillAreaColor() {
		return fillAreaColor;
	}

	/**
	 * Set the fill area color that will sit behind this bar chart.
	 * 
	 * @param fillAreaColor
	 *            The fill area color.
	 * @see Color
	 */
	public void setFillAreaColor(final Color fillAreaColor) {
		this.fillAreaColor = fillAreaColor;
	}
	
	/**
	 * Inner class to encapsulate data lines for bar charts.
	 * 
	 * @author Julien Chastang (julien.c.chastang at gmail dot com)
	 * 
	 * @see BarChart
	 */
	public static class DataLine{
		private final int dataLineSize;
		private final Color color;
		private final Priority priority;
		
		/**
		 * 
		 */
		DataLine(final int dataLineSize, final Color color, final Priority priority) {
			super();
			this.dataLineSize = dataLineSize;
			this.color = color;
			this.priority = priority;
		}

		/**
		 * Get the thickness of the data line.
		 * 
		 * @return The data line size.
		 */
		public int getDataLineSize() {
			return dataLineSize;
		}

		/**
		 * Get the data line color.
		 * 
		 * @return The data line color.
		 */
		public Color getColor() {
			return color;
		}

		/**
		 * Get the priority of this line.
		 * 
		 * @return {@link Priority}
		 * 
		 * @see Priority
		 */
		public Priority getPriority() {
			return priority;
		}
	}
}
